const path = require('path')
const basePath = __dirname
const { CleanWebpackPlugin } = require('clean-webpack-plugin')

module.exports = {
  context: path.resolve(basePath, 'src'),
  resolve: {
    extensions: ['.js']
  },
  entry: {
    app: ['./index.js'],
    vendor: [
      'lodash',
      'react',
      'react-dom'
    ]
  },
  output: {
    filename: "[name].[chunkhash].js"
  },
  module: {
    rules: [
      {
        test: /\.js$/,
        exclude: /node_modules/, // 排除 node_modules，不打包
        loader: 'babel-loader'
      }
    ]
  },
  plugins: [
    new CleanWebpackPlugin()
  ]
}